<template>
  <el-dialog
    class="base-dialog"
    :title="title"
    :visible.sync="isShowDialog"
    :append-to-body="true"
    :before-close="handleCloseDialog"
    custom-class="panna-dialog_medium"
    @closed="closedDialog"
  >
    <p slot="title">{{ title }}</p>
    <div class="basic-info">
      <el-form ref="filterForm" inline>
        <el-form-item :label="customer.itemName" prop="detectionItemName">
          <el-input
            v-model="filterForm.detectionItemName"
            :placeholder="customer.itemName"
            clearable
            @keyup.enter.native="getList('filter')"
          />
        </el-form-item>
        <el-form-item class="base-filter-button">
          <el-button type="primary" @click="getList('filter')">{{
            operateType.query
          }}</el-button>
          <el-button @click="cancelForm">{{ operateType.clear }}</el-button>
        </el-form-item>
      </el-form>
      <el-table
        ref="CustomerDetectionItemPrice"
        :data="dataList"
        element-loading-text="Loading"
        fit
        highlight-current-row
      >
        <el-table-column
          align="center"
          :label="customer.serialNumber"
          width="50"
        >
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>

        <el-table-column prop="detectionItemName" :label="customer.itemName">
        </el-table-column>
        <el-table-column
          prop="agreementPrice"
          :label="customer.agreementPrice1yuan"
        >
          <template slot-scope="scope">
            {{ scope.row.firstAgreementPrice / 100 }}
          </template>
        </el-table-column>
        <el-table-column
          prop="agreementPrice"
          :label="customer.agreementPrice2yuan"
        >
          <template slot-scope="scope">
            {{ scope.row.secondAgreementPrice / 100 }}
          </template>
        </el-table-column>
        <el-table-column
          prop="agreementPrice"
          :label="customer.agreementPrice2yuan"
        >
          <template slot-scope="scope">
            {{ scope.row.thirdAgreementPrice / 100 }}
          </template>
        </el-table-column>
        <el-table-column prop="agreementPrice" :label="customer.unitPrice">
          <template slot-scope="scope">
            {{ scope.row.agreementPrice / 100 }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </el-dialog>
</template>
<script>
import { GetSysBusinessDetectionItemGroupByNameList } from "../../../api/DetectionItemManage/SysBusinessDetectionItem";

export default {
  name: "CustomerDetectionItemDetail",
  components: {},
  props: {
    editId: {
      type: [String, Number],
      default: "",
    },
    isShowDialog: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      multipleSelection: [],
      total: 0,
      pageInfo: {
        pageIndex: 1,
        pageSize: 10,
      },
      dataList: [],
      title: this.$t("Customer.testingProjectAgreementPrice"),
      filterForm: {
        detectionItemName: "",
      },
    };
  },
  computed: {
    operateType() {
      return this.$t("ModuleSysBusiness.OperateType") || {};
    },
    customer() {
      return this.$t("Customer") || {};
    },
  },
  mounted() {},
  created() {
    this.getList();
  },
  methods: {
    cancelForm() {
      this.$refs.filterForm.resetFields();
      this.getList("filter");
    },

    getList() {
      GetSysBusinessDetectionItemGroupByNameList(this.filterForm)
        .then((res) => {
          this.dataList = res.data;
        })
        .catch((res) => {});
    },
    handleClick() {},

    // 关闭弹框
    handleClose() {
      // 动画结束后在清空表单 防止页面闪烁
      this.$emit("update:isShowDialog", false);
    },
    // 关闭客户弹框没保存
    handleCloseDialog() {
      // 动画结束后在清空表单 防止页面闪烁
      this.$emit("update:isShowDialog", false);
    },
    // 关闭弹框动画结束
    closedDialog() {
      // 动画结束后在清空表单 防止页面闪烁
    },
    handleCloseChildDialog() {
      this.$refs["ruleForm"].resetFields();
      this.isShowChildDialog = false;
    },
    closedChildDialog() {
      this.$refs["ruleForm"].resetFields();
      this.isShowChildDialog = false;
    },
  },
};
</script>
